package com.wjx.reservation_service.dao;

import com.wjx.reservation_service.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface UserDao {
    //根据用户名查询用户
    @Select("select * from user where username = #{username}")
    public User selectUserByUsername(String username);

    //添加用户
    @Insert("insert into user (username,password,authority) " +
            "values (#{username},#{password},#{authority})")
    public int addUser(User user);

    //根据id查询用户
    @Select("select * from user where id = #{id}")
    public User queryUserById(int id);

    //查询所有用户
    @Select("select * from user")
    public List<User> queryAllUser();

    //根据用户名模糊查询
    public List<User> queryLikeUsername(@Param("keyword") String keyword);

    //根据id更新用户
    @Update("update user set username = #{username},password = #{password}," +
            "authority = #{authority} where id = #{id}")
    public int updateUserById(User user);
    //根据id删除用户
    @Delete("delete from user where id = #{id}")
    public int deleteUserById(int id);

}
